package com.groupbuying.sysconfig.dto.app;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 微信公众号消息模板
 * @Auther Davidbieber
 * @Email davidbieber@163.com
 * @Date 2019/10/17 3:50 PM
 */
public class AppWechatInfo {

    private String toUser;
    private String templateId;
    private String url;
    private MiniProgramInfo miniProgramInfo;
    private List<AppDataInfo> data;

    public String getToUser() {
        return toUser;
    }

    public void setToUser(String toUser) {
        this.toUser = toUser;
    }

    public String getTemplateId() {
        return templateId;
    }

    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public MiniProgramInfo getMiniProgramInfo() {
        return miniProgramInfo;
    }

    public void setMiniProgramInfo(MiniProgramInfo miniProgramInfo) {
        this.miniProgramInfo = miniProgramInfo;
    }

    public List<AppDataInfo> getData() {
        return data;
    }

    public void setData(List<AppDataInfo> data) {
        this.data = data;
    }

    public AppWechatInfo(String toUser, String templateId, String url, MiniProgramInfo miniProgramInfo, List<AppDataInfo> data) {
        this.toUser = toUser;
        this.templateId = templateId;
        this.url = url;
        this.miniProgramInfo = miniProgramInfo;
        this.data = data;
    }

    public  AppWechatInfo addData(AppDataInfo dataInfo){
        if(this.data==null){
            this.data=new ArrayList<>();
        }
        this.data.add(dataInfo);
        return this;
    }

    public static AppWechatInfo.AppWechatInfoBuilder builder(){
        return new AppWechatInfo.AppWechatInfoBuilder();
    }

    /**
     * 模板消息构造器
     */
    public static class AppWechatInfoBuilder{
        private String toUser;
        private String templateId;
        private String url;
        private MiniProgramInfo miniProgramInfo;
        private List<AppDataInfo> data;

        AppWechatInfoBuilder(){};

        public AppWechatInfoBuilder toUser(String toUser) {
            this.toUser = toUser;
            return this;
        }

        public AppWechatInfoBuilder templateId(String templateId) {
            this.templateId = templateId;
            return this;
        }

        public AppWechatInfoBuilder url(String url) {
            this.url = url;
            return this;
        }

        public AppWechatInfoBuilder miniDataInfo(MiniProgramInfo miniProgramInfo) {
            this.miniProgramInfo = miniProgramInfo;
            return this;
        }

        public AppWechatInfoBuilder data(List<AppDataInfo> data) {
            this.data = data;
            return this;
        }

        public AppWechatInfo build(){
            return new AppWechatInfo(this.toUser,this.templateId,this.url,this.miniProgramInfo,this.data);
        }

        @Override
        public String toString(){
            return "AppWechatInfo.AppWechatInfoBuilder(toUser="+this.toUser+",templateId="+this.templateId+",url="+this.url+",miniProgramInfo="+this.miniProgramInfo +",data="+this.data+")";
        }
    }

}
